package com.aiti.lulian;

import com.aiti.lulian.entity.SysArea;
import com.aiti.lulian.mapper.SysAreaMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Component
public class AdCache {


    public Map<String,String> adCache = new HashMap<>(215);

    @Autowired
    private SysAreaMapper sysAreaMapper;

    @PostConstruct
    public void init(){
        List<SysArea> areaCode = sysAreaMapper.selectList(new QueryWrapper<SysArea>().likeRight("area_code", "37"));
        if(areaCode != null && !areaCode.isEmpty()){
            adCache = areaCode.stream().collect(Collectors.toMap(SysArea::getBaseId, SysArea::getBaseName));
        }
    }


}
